package com.cms.directive;

import java.io.IOException;
import java.io.Writer;
import java.util.Map;

import org.springframework.stereotype.Component;
import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer;

import com.common.web.SpringContextHolder;

import freemarker.core.Environment;
import freemarker.template.Configuration;
import freemarker.template.Template;
import freemarker.template.TemplateDirectiveBody;
import freemarker.template.TemplateException;
import freemarker.template.TemplateModel;
@Component
public class PagintaionDirective extends AbstractCustomDirective{

	@Override
	public void execute(Environment env, Map arg1, TemplateModel[] arg2,
			TemplateDirectiveBody body) throws TemplateException, IOException {
		// TODO Auto-generated method stub
		 Writer out=env.getOut();
		 out.append("l love you!");
		 env.__setitem__("a", "BBBBBBBBBB");
		 String tpl="tmp/pagintaion/1.html";
		 FreeMarkerConfigurer freeMarkerconfigurer=SpringContextHolder.getBean("freemarkerConfig");
		 Configuration conf=freeMarkerconfigurer.getConfiguration();
		 Template template = conf.getTemplate(tpl);
		 env.include(template);
		 body.render(env.getOut());  
	}



	
}
